<template>
  <div>
    <div id="mychart-line"></div>
  </div>
</template>

<script>
export default {
  data() {
    return {};
  },
  methods: {
    // 基本柱形图
    change() {
      const chartBox = this.$echarts.init(
        document.getElementById("mychart-line")
      );
      const option = {
        xAxis: {
          type: "category",
          data: ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"],
        },
        yAxis: {
          type: "value",
        },
        grid: {
          top: "5%",
          left: "3%",
          right: "3%",
          bottom: "10%",
          containLabel: true,
        },
        series: [
          {
            data: [150, 230, 224, 218, 135, 147, 260],
            type: "line",
          },
        ],
      };
      chartBox.setOption(option);
      // 根据页面大小自动响应图表大小
      window.addEventListener("resize", function () {
        chartBox.resize();
      });
    },
  },
  mounted() {
    this.change();
  },
};
</script>

<style lang="scss" scoped>
#mychart-line {
  width: 100%;
  height: 236px;
}
</style>
